<template>
    <div>
      <div class="header">
        <div class="h-left">
          <img @click="bac()" :src="'./static/lyl/back.png'" alt="">
        </div>
        <div class="h-right">
          <span>位置</span>
        </div>
      </div>
      <!--分类-->
      <ul class="fen_ul">
        <li @click="tab(item,index)" v-for="(item,index) in classData" :key="index" :class="con==index?'ctive':''">{{item.name}}{{index==0?'（'+count+'）':''}}</li>
      </ul>

      <!--达人-->
      <ul class="da_ul">
        <li v-for="(item,index) in expData" :key="index">
          <img @click="menav(item)" :src="item.avatar" alt="">
          <div @click="menav(item)" class="e_center">
            <p>{{item.user_login}}</p>
            <p>{{item.signature}}</p>
            <p>领域：{{item.territory}}</p>

          </div>
          <span @click="follow(item)">{{item.status==0?'+ 关注':'已关注'}}</span>
        </li>
      </ul>

      <transition name="van-slide-right">
        <div v-show="visible" class="tran_right">{{Fade}}</div>
      </transition>
    </div>
</template>

<script>
  import * as search from "../../../api/search.js"
    export default {
      name: "MorePerson",
      data(){
        return {
          Fade:'',
          visible:false,
          classData:[],
          con:0,
          expData:[],
          count:''
        }
      },
      beforeMount(){
        //获取舞种列表
        search.danceList().then(res=>{
          console.log('舞种列表',res);
          this.classData = res.data;
          this.count = res.count;
          //推荐达人全部
          let parms3 = {user_type:1,user_id:this.$store.state.user_id,all:1,dance_id:res.data[0].id};
          search.recommendUser(parms3).then(res=>{
            this.expData = res.data;
            console.log('推荐达人',res)
          });
        });
      },
      mounted(){
        mui.back = function() {
          window.history.go(-1);
        }
      },
      methods:{
        bac(){
          history.go(-1)
        },
        tab(item,i){
          this.con = i;
          if (i==0){
            //推荐达人
            let parms3 = {user_type:1,user_id:this.$store.state.user_id,all:1,dance_id:item.id};
            search.recommendUser(parms3).then(res=>{
              this.expData = res.data;
              console.log('推荐达人全部',res)
            });
          } else{
            //推荐达人
            let parms3 = {user_type:1,user_id:this.$store.state.user_id,dance_id:item.id};
            search.recommendUser(parms3).then(res=>{
              this.expData = res.data;
              console.log('推荐达人分类',res)
            });
          }
        },
        follow(item){
          if (item.status==0){
            item.status = 1;
            let flow = {follow_id:item.id,user_id:this.$store.state.user_id,status:1};
            search.follow(flow).then(res=>{
              console.log(res);
              this.visible = true;
              this.Fade = res.msg;
              setTimeout(() => {
                this.visible = false;
              }, 500);
            });
            search.followed(flow).then(res=>{
              console.log(res);
            })
          } else{
            item.status = 0;
            let flow = {follow_id:item.id,user_id:this.$store.state.user_id,status:0};
            search.follow(flow).then(res=>{
              console.log(res);
              this.visible = true;
              this.Fade = res.msg;
              setTimeout(() => {
                this.visible = false;
              }, 500);
            });
            search.followed(flow).then(res=>{
              console.log(res);
            })
          }
        },
        menav(item){
          this.$router.push({
            path: '/menav',
            query:{
              id:item.id
            }
          })
        }
      }
    }
</script>

<style scoped>
  .header{
    border-bottom: 1px solid #dcdcdc;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
  }
  .header .h-left img{
    width: 22px;
    vertical-align: bottom;
    margin-right: 30px;
  }
  .header .h-right span{
    font-size: 30px;
  }
  .fen_ul{
    padding: 40px 40px 0;
    border-bottom: 2px solid #dcdcdc;
    display: flex;
    flex-wrap: wrap;
  }
  .fen_ul li{
    font-size: 32px;
    margin:0 40px 40px 0;
  }
  .fen_ul .ctive{
    color: #884ca4;
  }

  .da_ul li{
    display: flex;
    justify-content: space-between;
    padding: 20px 40px;
    border-bottom: 2px solid #dcdcdc;
  }
  .da_ul li:last-child{
    border-bottom: none;
  }
  .da_ul li img{
    width: 130px;
    height: 130px;
    border-radius: 50%;
  }
  .da_ul li .e_center{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 55%;
  }
  .da_ul li .e_center p{
    font-size: 32px;
  }
  .da_ul li .e_center p:nth-child(2){
    font-size: 24px;
  }
  .da_ul li>span{
    width: 120px;
    height: 50px;
    line-height: 50px;
    text-align: center;
    border-radius: 10px;
    border: 2px solid #884ca4;
    color: #884ca4;
    font-size: 24px;
  }
  .tran_right{
    width: 220px;
    height: 60px;
    border-radius: 10px;
    text-align: center;
    line-height: 60px;
    font-size: 30px;
    top: 50%;
    left: 50%;
    position: fixed;
    background: rgba(0,0,0,0.6);
    color: #fff;
  }
</style>
